class Solution
{
 public:
  int NumberOf1(int n)
  {
    int res = 0;
    unsigned int un = n;
    while (un) res += un & 1, un >>= 1;
    return res;
  }
}